import qs from 'qs'
// axios
import request from '@/utils/request'

// user api @d_utils/request
export function getGroupandclassnum() {
  return request({
    url: `/clockin/getgroupandclassnum`,
    method: 'GET'
  })
}
// 获取审批列表
export function approvalGroupList() {
  return request({
    url: '/flow/list',
    method: 'get',
    loadText: '加载中...'
  })
}

export function approvalOpsUrl(type, id) {
  return request({
    url: '/flow/ops/' + type + (id ? '?id=' + id : ''),
    method: 'get',
    loadText: '加载中...'
  })
}
export function approvalTempInfo(type) {
  return request({
    url: '/flow/temp/' + type,
    method: 'get',
    loadText: '加载中...'
  })
}
export function approvalInstanceInfo(id) {
  return request({
    url: '/flow/instance/' + id,
    method: 'get',
    loadText: '加载中...'
  })
}
export function approvalTempSubmit(id, superId, superStepId, temp) {
  return request({
    url: '/flow/add',
    method: 'post',
    data: JSON.stringify({ Id: id, Temp: temp, SuperId: superId, SuperStepId: superStepId }),
    loadText: '加载中...'
  })
}

export function approvalTempEditSubmit(id, temp) {
  return request({
    url: '/flow/affair/edit',
    method: 'post',
    data: JSON.stringify({ Id: id, Temp: temp }),
    loadText: '加载中...'
  })
}
export function approvalFlowDetail(id) {
  return request({
    url: '/flow/affair/' + id,
    method: 'get',
    loadText: '加载中...'
  })
}
export function approverApprovalSubmit(id, sid, temp, template) {
  return request(
    {
      url: '/flow/affair/approver/approval',
      method: 'post',
      data: JSON.stringify({ FlowId: id, StepId: sid, Temp: temp, Template: template }),
      loadText: '加载中...'
    }
  )
}
export function approverRefuseSubmit(id, sid, temp) {
  return request(
    {
      url: '/flow/affair/approver/refuse',
      method: 'post',
      data: JSON.stringify({ FlowId: id, StepId: sid, Temp: temp }),
      loadText: '加载中...'
    }
  )
}
export function approverRejectSubmit(id, sid, rsid, temp) {
  return request(
    {
      url: '/flow/affair/approver/reject',
      method: 'post',
      data: JSON.stringify({ FlowId: id, StepId: sid, RejectStepId: rsid, Temp: temp }),
      loadText: '加载中...'
    }
  )
}
export function approverRejectStartSubmit(id, sid, temp) {
  return request(
    {
      url: '/flow/affair/approver/reject/start',
      method: 'post',
      data: JSON.stringify({ FlowId: id, StepId: sid, Temp: temp }),
      loadText: '加载中...'
    }
  )
}
export function approverRejectPrevSubmit(id, sid, temp) {
  return request(
    {
      url: '/flow/affair/approver/reject/prev',
      method: 'post',
      data: JSON.stringify({ FlowId: id, StepId: sid, Temp: temp }),
      loadText: '加载中...'
    }
  )
}
export function approverStartSubflow(id, sid, itemId) {
  return request({
    url: '/flow/affair/subflow/initial',
    method: 'post',
    data: JSON.stringify({ Id: id, StepId: sid, ItemId: itemId }),
    loadText: '加载中...'
  })
}
// 根据职员/关键字获取客户名称（没职员ID就查所有客户）
export function getMerchantList(params) {
  return request({
    url: '/merchant/common',
    method: 'POST',
    data: params,
    loadText: '加载中...'
  })
}
// 获取采购类型
export function Procurement() {
  return request({
    url: '/keycode/list/PurchaseType',
    method: 'get',
    loadText: '加载中...'
  })
}
// 获取补卡次数
export function GetCardNumber() {
  return request({
    url: '/clockin/supplementary/num',
    method: 'get',
    loadText: '加载中...'
  })
}
// 获取补卡类型
export function GetCardType() {
  return request({
    url: '/clockin/supplementary/state',
    method: 'get',
    loadText: '加载中...'
  })
}
// 获取职员
export function GetStaffList() {
  return request({
    url: '/report/stafflist',
    method: 'get',
    loadText: '加载中...'
  })
}

// 获取我发起的数据
export function getMystart(params) {
  return request({
    url: '/flow/page/created',
    method: 'post',
    data: JSON.stringify(params)
  })
}
// 获取我审批的数据
export function getMyapproval(params) {
  return request({
    url: '/flow/page/approval',
    method: 'post',
    data: JSON.stringify(params)
  })
}
// 获取我审批的数据
export function getMyApprovaled(params) {
  return request({
    url: '/flow/page/approvaled',
    method: 'post',
    data: JSON.stringify(params)
  })
}
// 获取待我审批的数据
export function getMyApprovaling(params) {
  return request({
    url: '/flow/page/approvaling',
    method: 'post',
    data: JSON.stringify(params)
  })
}

// 获取我审批type
export function getMyapprovalType() {
  return request({
    url: '/flow/affairs/value',
    method: 'get'
  })
}
export function getApprovelNum(type, time) {
  return request({
    url: '/approvel/num/' + type,
    method: 'post',
    data: JSON.stringify({
      Time: time
    })
  })
}

// 抄送我得
export function MyCarbonCopy(params) {
  return request({
    url: '/flow/myposter',
    method: 'post',
    data: JSON.stringify(params)
  })
}

// 已读  批量已读
export function AllReadMessage(params) {
  return request({
    url: '/flow/poster/read',
    method: 'post',
    data: JSON.stringify(params)
  })
}
// 获取操作类型
export function FlowAffairMap() {
  return request({
    url: '/flow/type',
    method: 'get'
  })
}
